import { createRequest } from '/@/api/service';
const module =
  process.env.APP_EDITION === 'hgy' ? 'ib/base/v1/AppSysUserApi/' : 'ib/user/v1/AppSysUserApi/';

/**
 * @function 用户登录
 * @param data
 * @param header
 * @returns {Promise}
 */
function LOGIN_APP(data: object = {}, header: object = {}): Promise<AppSysUserApi.LoginAppResp> {
  return createRequest(`${process.env.APP_API_URL}${module}loginApp`, data, header, 'POST');
}

/**
 * @function 用户列表查询
 * @param data
 * @param header
 * @returns {Promise}
 */
function SYS_USER_QUERY_APP(
  data: AppSysUserApi.SysUserQueryAppReq,
  header: object = {},
): Promise<AppSysUserApi.SysUserQueryAppResp> {
  return createRequest(`${process.env.APP_API_URL}${module}sysUserQueryApp`, data, header, 'POST');
}

/**
 * @function 开放用户列表查询
 * @param data
 * @param header
 * @returns {Promise}
 */
function OPEN_SYS_USER_QUERY_APP(
  data: AppSysUserApi.SysUserQueryAppReq,
  header: object = {},
): Promise<AppSysUserApi.SysUserQueryAppResp> {
  return createRequest(
    `${process.env.APP_API_URL}${module}open/sysUserQueryApp`,
    data,
    header,
    'POST',
  );
}

/**
 * @function 修改密码
 * @param data
 * @param header
 * @returns {Promise}
 */
function UPDATE_PWD_APP2(
  data: AppSysUserApi.UpdatePwdAppQuery,
  header: object = {},
): Promise<AppSysUserApi.UpdatePwdAppResp> {
  return createRequest(`${process.env.APP_API_URL}${module}updatePwdApp2`, data, header, 'POST');
}

/**
 * @function 修改头像
 * @param data
 * @param header
 * @returns {Promise}
 */
function UPDATE_USER_ICON_APP(
  data: AppSysUserApi.UpdateIconAppQuery,
  header: object = {},
): Promise<AppSysUserApi.UpdateIconAppResp> {
  return createRequest(
    `${process.env.APP_API_URL}${module}sysUserUpdateIconApp`,
    data,
    header,
    'POST',
  );
}

/**
 * @function 版本切换
 * @param data
 * @param header
 * @returns {Promise}
 */
function CHANGE_ROLE_PLATFORM_APP(
  data: AppSysUserApi.ChangeRolePlatformAppQuery,
  header: object = {},
): Promise<AppSysUserApi.ChangeRolePlatformAppResp> {
  return createRequest(
    `${process.env.APP_API_URL}${module}changeRolePlatformApp`,
    data,
    header,
    'POST',
  );
}

/**
 * @function 通讯录用户查询
 * @param data
 * @param header
 * @returns {Promise}
 */
function ADDRESS_BOOK_USER_QUERY_APP(
  data: AppSysUserApi.AddressBookUserQueryAppReq,
  header: object = {},
): Promise<AppSysUserApi.AddressBookUserQueryAppResp> {
  return createRequest(
    `${process.env.APP_API_URL}${module}addressBookUserQueryApp`,
    data,
    header,
    'POST',
  );
}

export {
  LOGIN_APP,
  SYS_USER_QUERY_APP,
  OPEN_SYS_USER_QUERY_APP,
  UPDATE_PWD_APP2,
  UPDATE_USER_ICON_APP,
  CHANGE_ROLE_PLATFORM_APP,
  ADDRESS_BOOK_USER_QUERY_APP,
};
